home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / dde_10.zip / DDE.C next >
Text File  |  1991-03-01  |  29KB  |  722 lines

  1.  
  2. /* Standard Library include files */
  3. #include <search.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <malloc.h>
  7. #include <string.h>
  8. #include <memory.h>
  9. #include <dos.h>
  10.  
  11. /* TCXL Library includes */
  12. #include <tcxldef.h>
  13. #include <tcxlsel.h>
  14. #include <tcxlkey.h>
  15. #include <tcxlwin.h>
  16. #include <tcxlvid.h>
  17. #include <tcxlkey.h>
  18. #include <tcxlcod.h>
  19. #include <tcxlmou.h>
  20.  
  21.  
  22.  
  23. /*
  24. ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  25. ▓▓                                                                   ▓▓
  26. ▓▓ Structure for PROCOMM PLUS dialing directory entry.               ▓▓
  27. ▓▓                                                                   ▓▓
  28. ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  29.        from the hook.c file that comes with procomm plus 2.0
  30. */
  31. typedef struct DDREC
  32.    {
  33.    char ddname[25],                    /* name */
  34.         ddphone[21];                   /* phone number */
  35.    int  ddbaud;                        /* baud rate as int */
  36.    char ddparity,                      /* parity as short int */
  37.         dddata,                        /* data bits as short int */
  38.         ddstop,                        /* stop bits as short int */
  39.         dddup,                         /* duplex as short int: 0 = full */
  40.         ddscript[9],                   /* ASPECT file w/o ext */
  41.         ddlast[9];                     /* last call: mm/dd/yy */
  42.    int  ddtotal;                       /* total connects */
  43.    char ddproto,                       /* default protocol as short int */
  44.         ddterm,                        /* terminal type as short int */
  45.         ddmode,                        /* 0 = mode, 1 = direct */
  46.         ddpassword[11],                /* like it says */
  47.         ddmacfile[9],                  /* keyboard macro file */
  48.         ddkbdfile[9],                  /* keyboard mapping file */
  49.         ddport,                        /* com port to use */
  50.         ddnotefile[9];                 /* note file */
  51.    } dd_entry;
  52.  
  53.  
  54.  
  55. #define DD_SIZE 200     /* size of the dialing directory with pcplus 2.0 */
  56.  
  57.  
  58. /*
  59.  *
  60.  *  Name: main()
  61.  *
  62.  *  Useage: called from o/s
  63.  *
  64.  *  Parameters: none
  65.  *
  66.  *  Returns: exits with errorlevel set to 0 if no problems occur
  67.  *
  68.  *  Function: main routine of PCPlus Dialing Directory Editor.
  69.  *
  70.  *  Written by: David Gersic                                    27 Feb 1991
  71.  *
  72.  */
  73.  
  74. void
  75. main()
  76. {
  77.  
  78.     /* variables */
  79.     dd_entry  *dial_dir,     /* old and new dialing directories */
  80.               *dial_new;
  81.     char      header[250],   /* header in dialing directory file */
  82.               *in_file,      /* input file name */
  83.               out_file[13];  /* output file name */
  84.  
  85.     /* functions */
  86.     int  read_ddir(char *, dd_entry *, char *),
  87.          write_ddir(char *, dd_entry *, char *),
  88.          modify_ddir(dd_entry *,dd_entry *);
  89.     char *get_in_file(void);
  90.     int  get_out_file(char *);
  91.  
  92.     TcxlInit();         /* initialize library */
  93.     VcurHid(0);         /* turn off cursor */
  94.  
  95.     Wopen(0,0,24,79,BOX_SPA,LGREY | _RED,LGREY | _RED);    /* main window */
  96.                                   /* set up title and credits */
  97.     Wgotoxy(24,0);
  98.     Wputs("      David Gersic                                        17 Feb. 1991");
  99.     Wopen(0,0,23,79,BOX_HOR,LGREY | _RED,LGREY | _RED);
  100.     Wtitle(" ProcommPlus 2.0 Dialing Directory Editor v1.0 ",TTL_CNT,YELLOW|_RED);
  101.  
  102.     while(in_file=get_in_file())       /* get input file name */
  103.     {                             /* loop terminates when <esc> is pressed */
  104.          if((dial_dir=(dd_entry *)malloc((DD_SIZE)*sizeof(dd_entry))) == NULL)
  105.          {
  106.               fprintf(stderr,"Malloc failed.\nExiting to DOS.\n");
  107.               exit(1);
  108.          }
  109.          if((dial_new=(dd_entry *)malloc((DD_SIZE)*sizeof(dd_entry))) == NULL)
  110.          {
  111.               fprintf(stderr,"Malloc failed.\nExiting to DOS.\n");
  112.               exit(1);
  113.          }
  114.          read_ddir(in_file,dial_dir,header);   /* read in dialing directory */
  115.          modify_ddir(dial_dir,dial_new);       /* re-arrange directory */  
  116.          Wclose();                          /* close edit windows */
  117.          Wclose();
  118.          if(get_out_file(out_file)==0)         /* get output file name */
  119.               write_ddir(out_file,dial_new,header); /* write out new dir */
  120.          free(dial_dir);                    /* free dynamic memory */
  121.          free(dial_new);
  122.     }
  123.     WcloseAll();                            /* close all windows and exit */
  124.     VcurHid(1);
  125.     exit(0);
  126. } /* end main() */
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. /*
  134.  *
  135.  *  Name: read_ddir()
  136.  *
  137.  *  Useage: read_ddir(char *dd_name, dd_entry *dial_dir, char *header)
  138.  *
  139.  *  Parameters:    char *dd_name       filename of directory file to read in
  140.  *                 dd_entry *dial_dir  where to put directory read in
  141.  *                 char *header        where to store header
  142.  *
  143.  *  Returns: 0
  144.  *
  145.  *  Function: To read in a ProcommPlus 2.0 dialing directory file.
  146.  *
  147.  *  Written by: David Gersic                                    27 Feb 1991
  148.  *
  149.  */
  150.  
  151. int
  152. read_ddir(char *dd_name, dd_entry *dial_dir, char *header)
  153. {
  154.     FILE *dd_file;
  155.     int i=0;
  156.  
  157.     dd_file=fopen(dd_name,"rb");  /* open file for input, no translation */
  158.  
  159.     if(dd_file==NULL)             /* file not open */
  160.     {
  161.          fprintf(stderr,"Error opening input file.\nExiting to DOS.\n");
  162.          exit(1);
  163.     }
  164.  
  165.     fread(header,250,1,dd_file);  /* read header */
  166.     while(i<DD_SIZE)              /* read dialing directory entries */
  167.     {
  168.          if(fread((dial_dir+i),114,1,dd_file) != 1)   /* one at a time */
  169.          {
  170.               if(ferror(dd_file))                     /* error reading file */
  171.                    perror("Error reading file.\n");
  172.               else
  173.                    fprintf(stderr,"Unknown error reading file.\n");
  174.               fprintf(stderr,"Aborting!\n");
  175.               exit(1);                           /* abort to DOS */
  176.          }
  177.          i++;
  178.     }
  179.     fclose(dd_file);    
  180.     return(0);
  181. } /* end read_ddir() */
  182.  
  183.  
  184. /*
  185.  *
  186.  *  Name: write_ddir()
  187.  *
  188.  *  Useage: write_ddir(char *dd_name, dd_entry *dial_dir, char *header)
  189.  *
  190.  *  Parameters:    char *dd_name       filename to write out to
  191.  *                 dd_entry *dial_dir  memory image of directory to write out
  192.  *                 char *header        header saved by read_ddir()
  193.  *
  194.  *  Returns: 0
  195.  *
  196.  *  Function: To write out a ProcommPlus 2.0 dialing directory read in by
  197.  *            read_ddir().
  198.  *
  199.  *  Written by: David Gersic                                    27 Feb 1991
  200.  *
  201.  */
  202.  
  203. int
  204. write_ddir(char *dd_name, dd_entry *dial_dir, char *header)
  205. {
  206.     FILE *out_file;
  207.     int  i=0;
  208.  
  209.     out_file=fopen(dd_name,"wb");      /* open file, no translation */
  210.     if(out_file==NULL)                 /* file not open */
  211.     {
  212.          fprintf(stderr,"Error opening output file.\nExiting to DOS.\n");
  213.          exit(1);
  214.     }
  215.  
  216.     fwrite(header,250,1,out_file);     /* write header */
  217.     while(i<DD_SIZE)              /* write dialing directory entries */
  218.     {
  219.          if(fwrite((dial_dir+i),114,1,out_file) != 1) /* one at a time */
  220.          {
  221.               if(ferror(out_file))               /* error writing to file */
  222.                    perror("Error writing file.\n");
  223.               else
  224.                    fprintf(stderr,"Unknown error writing file.\n");
  225.               fprintf(stderr,"Aborting!\n");
  226.               exit(1);                      /* exit to o/s */
  227.          }
  228.          i++;
  229.     }
  230.     fclose(out_file);
  231.     return(0);
  232. } /* end write_ddir() */
  233.  
  234.  
  235. /*
  236.  *
  237.  *  Name: get_in_file()
  238.  *
  239.  *  Useage: get_in_file()
  240.  *
  241.  *  Parameters: none
  242.  *
  243.  *  Returns: pointer to the filename to be opened.
  244.  *
  245.  *  Function: To get a filename from a pick-list. It passes the name back
  246.  *            to the caller.
  247.  *
  248.  *  Written by: David Gersic                                    27 Feb 1991
  249.  *
  250.  */
  251.  
  252. char *
  253. get_in_file()
  254. {
  255.     char *file_name;
  256.     VOID  CTYP  AddShadow(NOARG); /* add drop-shadow to open window */
  257.      
  258.     Wgotoxy(2,24);                /* text prompt on screen */
  259.     WsetTxt(WHITE | _RED);
  260.     Wputf("Dialing Directory To Modify.");
  261.  
  262.     file_name=SelFile(5,30,20,43,BOX_HOR,LGREY|_BLUE,LGREY|_BLUE,BLUE|_LGREY,0,"*.DIR",AddShadow);
  263.     Wclear();
  264.     return(file_name);
  265. } /* end get_in_file() */
  266.  
  267.  
  268. /* very small function, called to add a shadow to a window */
  269. VOID  CTYP
  270. AddShadow(NOARG)
  271. {
  272.    Wshadow(LGREY|_BLACK);
  273. }
  274.  
  275.  
  276.  
  277. /*
  278.  *
  279.  *  Name: get_out_file()
  280.  *
  281.  *  Useage: get_out_file(char *out_file)
  282.  *
  283.  *  Parameters:    char *out_file      where to put the filename
  284.  *
  285.  *  Returns: 0
  286.  *
  287.  *  Function: To get a filename input from the user. It only allows
  288.  *            eight characters to be input, and forces the extention
  289.  *            to be ".dir". I couldn't find a way to disallow the '.'
  290.  *            character in the input string, so I just strip anything
  291.  *            after a '.' and tack on a '.dir'. Sort of a kludge, but
  292.  *            it works.     
  293.  *
  294.  *  Written by: David Gersic                                    27 Feb 1991
  295.  *
  296.  */
  297.  
  298. int
  299. get_out_file(char *out_file)
  300. {
  301.     int  i=0;
  302.  
  303.     if(MouInit)    /* if mouse has been found */
  304.     {
  305.          MouLvl=MOU_KEYS;    /* allow mouse click for <esc> and <ret> keys */
  306.     }
  307.  
  308.     VcurHid(1);         /* turn on cursor for text input */
  309.     Wgotoxy(13,13);     /* screen prompts */
  310.     WsetTxt(WHITE|_RED);
  311.     Wputf("Filename with no extention.  <Esc> to abort changes.");
  312.     Wopen(9,15,11,64,BOX_HOR,LGREY | _BLUE,LGREY | _BLUE);
  313.     Wshadow(LGREY|_BLACK);
  314.     Wgotoxy(0,0);
  315.     WsetTxt(WHITE | _BLUE);
  316.     if(KwGetFmt(out_file, "' Save into <filename>? ' !CUR! F!R!FFFFFFF")!=ERR_NUL)
  317.     {              /* esc key pressed */
  318.          VcurHid(0);    /* hide cursor again, close window and return */
  319.          Wclose();
  320.          Wclear();
  321.          return(1);
  322.     }
  323.     else           /* filename typed in */
  324.     {
  325.          while(i<8)                         /* strip extention off */
  326.          {
  327.               i++;
  328.               if( *(out_file+i) == '.')
  329.                    *(out_file+i)='\0';
  330.          }
  331.          VcurHid(0);
  332.          strcat(out_file,".DIR");      /* put on ".dir" */
  333.          Wclose();                     /* close window and return */
  334.          Wclear();
  335.          return(0);
  336.     }
  337. } /* end get_out_file() */  
  338.  
  339.  
  340.  
  341.  
  342. /*
  343.  *
  344.  *  Name: modify_ddir()
  345.  *
  346.  *  Useage: modify_ddir(dd_entry *dial_dir,dd_entry *dial_new)
  347.  *
  348.  *  Parameters: dd_entry *dial_dir     dialing directory image to modify
  349.  *              dd_entry *dial_new     where to put the new directory 
  350.  *
  351.  *  Returns: 0 
  352.  *
  353.  *  Function: This is the function that does all of the "work". User input
  354.  *            is taken from either keyboard or mouse, and processed. The
  355.  *            new dialing directory is built from the old one, and
  356.  *            modifications are shown on the screen in a window. Very little
  357.  *            error checking is done, but the code is fairly robust so
  358.  *            no errors "should" occur.
  359.  *
  360.  *  Written by: David Gersic                                    27 Feb 1991
  361.  *
  362.  */
  363.  
  364. int
  365. modify_ddir(dd_entry *dial_dir,dd_entry *dial_new)
  366. {
  367.     dd_entry  *index[DD_SIZE],    /* arrays of pointers to set up indexes */
  368.               *new[DD_SIZE];      /* into the real copies of the dialing directories */
  369.     WndT      new_win,            /* window "handle"s */
  370.               old_win;
  371.     KeyT      in_key=0;           /* keyboard input variable */
  372.     int       i,                  /* scratch */
  373.               new_ndx=0,          /* index variables into index arrays */
  374.               old_ndx=0,
  375.               new_lin=0,
  376.               old_lin=0;
  377.  
  378.          /* set up screen */
  379.     new_win=Wopen(1,41,21,75,BOX_HOR,LGREY | _BLUE,LGREY | _BLUE);
  380.     Wtitle(" Destination ",TTL_CNT,YELLOW|_BLUE);
  381.     Wshadow(LGREY|_BLACK);
  382.     Wbprintc(BRD_RGT,1,WHITE|_BLUE,'');
  383.     Wbprintc(BRD_RGT,19,WHITE|_BLUE,'');
  384.  
  385.     old_win=Wopen(1,2,21,36,BOX_HOR,LGREY | _BLUE,LGREY | _BLUE);
  386.     Wtitle(" Source ",TTL_CNT,YELLOW|_BLUE);
  387.     Wshadow(LGREY|_BLACK);
  388.     Wbprintc(BRD_RGT,1,WHITE|_BLUE,'');
  389.     Wbprintc(BRD_RGT,19,WHITE|_BLUE,'');
  390.     
  391.     /* set up pointers to array entries */
  392.     for(i=0;i<DD_SIZE;i++)
  393.     {
  394.          index[i]=(dial_dir+i);
  395.          new[i]=NULL;        /* display entries on "old" half of screen */
  396.          if(i<19)            /* room for 19 entries on screen at a time */
  397.               Wputf("  %3d %s\n",i+1,index[i]->ddname);    /* display entry */
  398.     }
  399.  
  400.     if(MouInit)    /* if mouse was found */
  401.     {
  402.          MShome();                /* home mouse cursor */
  403.          MSlimit(2,2,20,75);      /* set on-screen limit on movement */
  404.          MouLvl=MOU_CURS;         /* set level of support */
  405.          MSshow();                /* show mouse cursor */
  406.          MouBtn=0;                /* intitialize variable */
  407.     }
  408.  
  409.          /* put up "blank" new window and number lines */
  410.     Wactiv(new_win);
  411.     for(i=1;i<20;i++)
  412.          Wputf("  %3d\n",i);
  413.  
  414.     KeyClear();                        /* clear keyboard buffer */
  415.  
  416.     Wactiv(old_win);
  417.     do {                               /* main body of loop */
  418.          Wgotoxy(old_lin,2);           /* highlight current "old" entry */
  419.          WsetTxt(BLUE | _LGREY);
  420.          Wputf("%3d %-25s",old_ndx+1,index[old_ndx]->ddname);
  421.          while(!KeyEvent()); /* spin until . . . */
  422.          if(MouBtn & 0x01)        /* if event was mouse click */
  423.          {         /* which side of screen was it on */
  424.               if(MouCol > 2 && MouCol <= 36)  /* left hand window, old dir */
  425.               {
  426.                    Wgotoxy(old_lin,2);      /* highlight off */
  427.                    WsetTxt(LGREY | _BLUE);
  428.                    Wputf("%3d %-25s",old_ndx+1,index[old_ndx]->ddname);
  429.  
  430.                    if(MouRow==2 && MouCol==36)   /* scroll up arrow */
  431.                    {
  432.                         WscrWin(1,DIR_DWN);
  433.                         Wgotoxy(0,2);
  434.                         if(old_ndx-old_lin-1 < 0)
  435.                              Wputf("%3d %-25s",old_ndx-old_lin+200,index[old_ndx-old_lin+199]->ddname);
  436.                         else 
  437.                              Wputf("%3d %-25s",old_ndx-old_lin,index[old_ndx-old_lin-1]->ddname);
  438.                         old_lin=(old_lin+1);
  439.                         if(old_lin > 18)
  440.                         {
  441.                              old_ndx--;
  442.                              if(old_ndx<0)
  443.                                   old_ndx=199;
  444.                              old_lin=18;
  445.                         }
  446.                         _Delay(1);     /* slight delay, slow it down */
  447.                    }
  448.                    else if(MouRow==20 && MouCol==36)  /* scroll down arrow */
  449.                    {
  450.                         WscrWin(1,DIR_UP);
  451.                         Wgotoxy(18,2);
  452.                         Wputf("%3d %-25s",((old_ndx-old_lin+19)%200)+1,index[(old_ndx-old_lin+19)%200]->ddname);
  453.                         old_lin=old_lin-1;
  454.                         if(old_lin < 0)
  455.                         {
  456.                              old_ndx=(old_ndx+1)%200;
  457.                              old_lin=0;
  458.                         }
  459.                         _Delay(1);     /* slow down screen scroll */
  460.                    }
  461.                    else /* within window, set new "current" pointer */
  462.                    {
  463.                         old_ndx=(old_ndx-old_lin+MouRow-2)%200;
  464.                         if(old_ndx<0)
  465.                              old_ndx+=200;
  466.                         old_lin=MouRow-2;
  467.                    }
  468.               }
  469.               else if(MouCol > 41 && MouCol <=75)    /* right hand window */
  470.               {
  471.                    Wactiv(new_win);              /* switch active window */
  472.  
  473.                    if(MouRow==2 && MouCol==75)   /* scroll up arrow */
  474.                    {
  475.                         WscrWin(1,DIR_DWN);
  476.                         Wgotoxy(0,2);
  477.                         if(new_ndx-new_lin-1 < 0)
  478.                              if(new[new_ndx-new_lin+199]==NULL)
  479.                                   Wputf("%3d %-25s",new_ndx-new_lin+200," ");
  480.                              else
  481.                                   Wputf("%3d %-25s",new_ndx-new_lin+200,new[new_ndx-new_lin+199]->ddname);
  482.                         else 
  483.                              if(new[new_ndx-new_lin-1]==NULL)
  484.                                   Wputf("%3d %-25s",new_ndx-new_lin," ");
  485.                              else
  486.                                   Wputf("%3d %-25s",new_ndx-new_lin,new[new_ndx-new_lin-1]->ddname);
  487.                         new_lin=(new_lin+1);
  488.                         if(new_lin > 18)
  489.                         {
  490.                              new_ndx--;
  491.                              if(new_ndx<0)
  492.                                   new_ndx=199;
  493.                              new_lin=18;
  494.                         }
  495.                    }
  496.                    else if(MouRow==20 && MouCol==75)  /* scroll down arrow */
  497.                    {
  498.                         WscrWin(1,DIR_UP);
  499.                         Wgotoxy(18,2);
  500.                              if(new[(new_ndx-new_lin+19)%200]==NULL)
  501.                                   Wputf("%3d %-25s",((new_ndx-new_lin+19)%200)+1," ");
  502.                              else
  503.                                   Wputf("%3d %-25s",((new_ndx-new_lin+19)%200)+1,new[(new_ndx-new_lin+19)%200]->ddname);
  504.                         new_lin=new_lin-1;
  505.                         if(new_lin < 0)
  506.                         {
  507.                              new_ndx=(new_ndx+1)%200;
  508.                              new_lin=0;
  509.                         }
  510.                    }
  511.                    else      /* click in window, put new entry */
  512.                    {
  513.                         new_ndx=(new_ndx+MouRow-2-new_lin);
  514.                         if(new_ndx < 0)
  515.                              new_ndx+=200;
  516.                         if(new_ndx == 200)
  517.                              new_ndx=0;
  518.                         new_ndx=new_ndx%200;
  519.  
  520.                         new[new_ndx]=index[old_ndx];
  521.                         new_lin=MouRow-2;
  522.                         Wgotoxy(new_lin,2);
  523.                         WsetTxt(LGREY | _BLUE);
  524.                         Wputf("%3d %-25s",new_ndx+1,index[old_ndx]->ddname);
  525.                         _Delay(2);     /* slight delay */
  526.                    }
  527.                    Wactiv(old_win);    /* reactivate "old" window */
  528.               }
  529.               MouBtn=0;                /* re-initialize button variable */
  530.          }
  531.          else if(MouBtn & 0x02)   /* right button */
  532.          {
  533.               MouBtn=0;
  534.               break;                        /* treat right button as <esc> */
  535.          }
  536.          else /* must have been a keypress */
  537.          {
  538.               in_key=KeyGetc();                  /* get keyboard input */
  539.               switch (in_key) {                  /* process . . . */
  540.                    case Key_Up:
  541.                         Wgotoxy(old_lin,2);
  542.                         WsetTxt(LGREY | _BLUE);
  543.                         Wputf("%3d %-25s",old_ndx+1,index[old_ndx]->ddname);
  544.                         old_ndx--;
  545.                         if(old_ndx<0)
  546.                              old_ndx=199;
  547.                         old_lin--;
  548.                         if(old_lin<0)
  549.                         {
  550.                              WscrWin(1,DIR_DWN);
  551.                              old_lin=0;
  552.                         }
  553.                         break;
  554.                    case Key_Dwn:
  555.                         Wgotoxy(old_lin,2);
  556.                         WsetTxt(LGREY | _BLUE);
  557.                         Wputf("%3d %-25s",old_ndx+1,index[old_ndx]->ddname);
  558.                         old_ndx=(old_ndx+1) % 200;
  559.                         old_lin++;
  560.                         if(old_lin>18)
  561.                         {
  562.                              WscrWin(1,DIR_UP);
  563.                              old_lin=18;
  564.                         }
  565.                         break;
  566.                    case Key_PgDn:
  567.                         Wgotoxy(old_lin,2);
  568.                         WsetTxt(LGREY | _BLUE);
  569.                         Wputf("%3d %-25s",old_ndx+1,index[old_ndx]->ddname);
  570.                         old_ndx=old_ndx+18-old_lin;     /* added -old_lin */
  571.                         if(old_ndx>199)
  572.                              old_ndx-=199;
  573.                         old_lin=0;
  574.                              /* redraw screen */
  575.                         Wclear();
  576.                         for(i=0;i<19;i++)
  577.                         {
  578.                              Wgotoxy(i,2);
  579.                              Wputf("%3d %-25s",((old_ndx+i)%200)+1,index[(old_ndx+i)%200]->ddname);
  580.                         }
  581.                         break;
  582.                    case Key_PgUp:
  583.                         Wgotoxy(old_lin,2);
  584.                         WsetTxt(LGREY | _BLUE);
  585.                         Wputf("%3d %-25s",old_ndx+1,index[old_ndx]->ddname);
  586.                         old_ndx=old_ndx-18-old_lin;     /* added -old_lin */
  587.                         if(old_ndx<0)
  588.                              old_ndx+=199;
  589.                         old_lin=0;
  590.                              /* redraw screen */
  591.                         Wclear();
  592.                         for(i=0;i<19;i++)
  593.                         {
  594.                              Wgotoxy(i,2);
  595.                              Wputf("%3d %-25s",((old_ndx+i)%200)+1,index[(old_ndx+i)%200]->ddname);
  596.                         }
  597.                         break;
  598.                    case Key_Ent:       /* switch windows and put current old_entry at selected new_entry */
  599.                         Wactiv(new_win);
  600.                         Wgotoxy(new_lin,2);
  601.                         WsetTxt(BLUE | _LGREY);  /* highlight bar */
  602.                         if(new[new_ndx]==NULL)
  603.                              Wputf("%3d %-25s",new_ndx+1,"     ");
  604.                         else
  605.                              Wputf("%3d %-25s",new_ndx+1,new[new_ndx]->ddname);
  606.                         do {                     /* get keyboard input to select new entry to fill */
  607.                              in_key=KeyGetc();
  608.                              Wgotoxy(new_lin,2);
  609.                              WsetTxt(LGREY | _BLUE);  /* highlight off */
  610.                              if(new[new_ndx]==NULL)
  611.                                   Wputf("%3d %-25s",new_ndx+1,"     ");
  612.                              else
  613.                                   Wputf("%3d %-25s",new_ndx+1,new[new_ndx]->ddname);
  614.                              switch(in_key) {    /* process keystroke */
  615.                                   case Key_Up:
  616.                                        new_ndx--;
  617.                                        new_lin--;
  618.                                        if(new_lin<0)
  619.                                        {
  620.                                             WscrWin(1,DIR_DWN);
  621.                                             new_lin=0;
  622.                                        }
  623.                                        if(new_ndx<0)
  624.                                             new_ndx=199;
  625.                                        break;
  626.                                   case Key_Dwn:
  627.                                        new_ndx=(new_ndx+1)%200;
  628.                                        new_lin++;
  629.                                        if(new_lin>18)
  630.                                        {
  631.                                             WscrWin(1,DIR_UP);
  632.                                             new_lin=18;
  633.                                        }
  634.                                        break;
  635.                                   case Key_PgDn:
  636.                                        Wgotoxy(new_lin,2);
  637.                                        WsetTxt(LGREY | _BLUE);
  638.                                        if(new[new_ndx]==NULL)
  639.                                             Wputf("%3d %-25s",new_ndx+1," ");
  640.                                        else
  641.                                             Wputf("%3d %-25s",new_ndx+1,new[new_ndx]->ddname);
  642.                                        new_ndx=new_ndx+18-new_lin;
  643.                                        if(new_ndx>199)
  644.                                             new_ndx-=199;
  645.                                        new_lin=0;
  646.                                             /* redraw screen */
  647.                                        Wclear();
  648.                                        for(i=0;i<19;i++)
  649.                                        {
  650.                                             Wgotoxy(i,2);
  651.                                             if(new[(new_ndx+i)%200]==NULL)
  652.                                                  Wputf("%3d %-25s",((new_ndx+i)%200)+1," ");
  653.                                             else
  654.                                                  Wputf("%3d %-25s",((new_ndx+i)%200)+1,new[(new_ndx+i)%200]->ddname);
  655.                                        }
  656.                                        break;
  657.                                   case Key_PgUp:
  658.                                        Wgotoxy(new_lin,2);
  659.                                        WsetTxt(LGREY | _BLUE);
  660.                                        if(new[new_ndx]==NULL)
  661.                                             Wputf("%3d %-25s",new_ndx+1," ");
  662.                                        else
  663.                                             Wputf("%3d %-25s",new_ndx+1,new[new_ndx]->ddname);
  664.                                        new_ndx=new_ndx-18-new_lin;
  665.                                        if(new_ndx<0)
  666.                                             new_ndx+=199;
  667.                                        new_lin=0;
  668.                                             /* redraw screen */
  669.                                        Wclear();
  670.                                        for(i=0;i<19;i++)
  671.                                        {
  672.                                             Wgotoxy(i,2);
  673.                                             if(new[(new_ndx+i)%200]==NULL)
  674.                                                  Wputf("%3d %-25s",((new_ndx+i)%200)+1," ");
  675.                                             else
  676.                                                  Wputf("%3d %-25s",((new_ndx+i)%200)+1,new[(new_ndx+i)%200]->ddname);
  677.                                        }
  678.                                        break;
  679.                              } /* end switch */  /* new line selected */
  680.                              Wgotoxy(new_lin,2);
  681.                              WsetTxt(BLUE | _LGREY);  /* highlight new current entry */
  682.                              if(new[new_ndx]==NULL)
  683.                                   Wputf("%3d %-25s",new_ndx+1,"     ");
  684.                              else
  685.                                   Wputf("%3d %-25s",new_ndx+1,new[new_ndx]->ddname);
  686.                         } while (in_key!=Key_Ent && in_key!=Key_Esc); /* loop until ... */
  687.                         Wgotoxy(new_lin,2);
  688.                         WsetTxt(LGREY | _BLUE);  /* in "normal" attributes */
  689.                         if(in_key!=Key_Esc) /* if <return>, update "new" index */
  690.                         {
  691.                              Wputf("%3d %-25s",new_ndx+1,index[old_ndx]->ddname);
  692.                              new[new_ndx]=index[old_ndx];
  693.                         }
  694.                         else      /* do not update "new" index, return to the way it was */
  695.                         {
  696.                              if(new[new_ndx]==NULL)
  697.                                   Wputf("%3d %-25s",new_ndx+1," ");
  698.                              else
  699.                                   Wputf("%3d %-25s",new_ndx+1,new[new_ndx]->ddname);
  700.                         }
  701.                         Wactiv(old_win);    /* reactivate old window */
  702.                         in_key=0;
  703.                         break;
  704.               } /* end switch */
  705.          } /* end if */
  706.     } while(in_key != Key_Esc); /* do loop until <esc> pressed */
  707.  
  708.     for(i=0;i<DD_SIZE;i++)   /* use indexes built above to build new dialing directory */
  709.     {
  710.          if(new[i]!=NULL)
  711.               memcpy((dial_new+i),new[i],114);
  712.          else
  713.               memcpy((dial_new+i),index[i],114);
  714.     }
  715.     if(MouInit)    /* turn off mouse cursor */
  716.     {
  717.          MouLvl=MOU_NONE;    /* disable mouse support */
  718.          MShide();
  719.     }
  720.     return(0);
  721. } /* end modify_ddir() */
  722.